Skip to content

feat: add documents table for Git-backed Headless CMS#34

Merged
pyramation merged 7 commits intomainfrom
devin/1777497144-add-documents-table
Apr 30, 2026
Merged

feat: add documents table for Git-backed Headless CMS#34
pyramation merged 7 commits intomainfrom
devin/1777497144-add-documents-table

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

@pyramation pyramation commented Apr 29, 2026

Summary

Adds a documents blueprint schema for version-controlled files (Git-backed Headless CMS primitive) and removes the ORG_NODES abstraction across all provision schemas.

1. Documents table (new)

New schema file: packages/provision/src/schemas/documents.ts

  • documents table with fields: title, content, metadata (jsonb), repo_name, file_path, commit_hash, tags
  • SearchUnified node with chunks: {} for automatic chunking (generates documents_chunks table, like notes_chunks)
  • BM25 index on content, GIN index on tags, btree indexes on repo_name and file_path

Junction tables (via cross-relations.ts):

  • company_documents — link documents to companies
  • project_documents — link documents to projects

Orchestrator (provision.ts):

  • Documents schema registered before Cross-Relations

2. Remove ORG_NODES, use string shorthand (cleanup)

  • Deleted the ORG_NODES constant from blueprint.tsDataId is added automatically, DataTimestamps doesn't need include_id: false
  • Replaced all ...ORG_NODES spreads with 'DataTimestamps' string shorthand (the BlueprintNode union already supports plain strings natively)
  • Cleaned up ORG_NODES imports from all 8 schema files

Review & Testing Checklist for Human

  • Run pnpm run provision to verify documents table + chunks + junctions are created
  • Spot-check that existing tables (notes, contacts, etc.) still provision correctly with 'DataTimestamps' shorthand
  • Run pnpm run export:all to regenerate SQL module and SDK/CLI

Notes

  • 10 files changed, net -18 lines (removed more boilerplate than added)
  • The provision/export workflow generates actual SQL migrations, RLS, triggers, and SDK types — this PR only touches blueprint definitions

Link to Devin session: https://app.devin.ai/sessions/2a4faca18f1a4b4aaf3d8e1162f67e0d
Requested by: @pyramation

Add a documents blueprint schema for version-controlled markdown files
with SearchUnified (embedding + BM25 + chunks), repo/path/commit tracking,
and frontmatter metadata support.

- New documents.ts schema: documents table with chunked embeddings
- Junction tables: company_documents, project_documents
- BM25/btree/GIN indexes for content, repo_name, file_path, tags
- Registered in provision.ts orchestrator (before cross-relations)
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Make the documents table format-agnostic instead of forcing markdown.
DataId is added automatically; ORG_NODES import removed.
…thand

- Remove ORG_NODES constant from blueprint.ts (DataId is automatic)
- Replace all ...ORG_NODES spreads with 'DataTimestamps' string shorthand
- Clean up ORG_NODES imports from all schema files
- BlueprintNode union type supports plain string shorthand natively
… CLI

- Add 'DataId' node to all schema files (required for PK constraint creation)
- Run provision: all 11 schemas (including Documents) applied successfully
- Run export:pgpm: SQL migrations generated in packages/agentic-db/
- Run generate:all: GraphQL schema, ORM SDK, and CLI regenerated
- Documents table includes SearchUnified (embedding + BM25 + chunks)
- Junction tables: company_documents, project_documents
SearchUnified already creates a BM25 index on embedding_text (which
includes content via source_fields). The explicit content BM25 index
caused duplicate filter/score fields in the GraphQL API and
double-counted content relevance in the composite searchScore.

Removed from:
- documents.ts: content BM25 index
- crm.ts: notes content BM25 index

Re-provisioned and regenerated all output.
…export

feat: provision + export documents table with generated SQL, SDK, and CLI
@pyramation pyramation merged commit bc1985e into main Apr 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant